<div class="da-list-wrap">
  <div class="da-content-banner">
    <d-breadcrumb>
      <d-breadcrumb-item><a routerLink="/">{{ 'inventory.breadcrumb.home' | translate }}</a></d-breadcrumb-item>
      <d-breadcrumb-item>{{ 'inventory.breadcrumb.productInventoryRk' | translate }}</d-breadcrumb-item>
    </d-breadcrumb>
  </div>
  <div class="da-content-wrapper">
    <div class="da-list-container">
      <div class="da-list-header">
        <d-row>
          <d-col [dSpan]="24">
            <div>
              <input dTextInput style="width: 180px;" [error]="false" placeholder="单据编码" name="code"
                [(ngModel)]="productionWarehousingNum" class="me-2">
              <d-range-datepicker-pro name="开始结束时间" [(ngModel)]="value1" (ngModelChange)="start$end()"
                [placeholder]="['起始日期','截至日期']"></d-range-datepicker-pro>
              <d-button id="primaryBtn" style="margin-left: 8px" (btnClick)="filter2()"><i
                  class="icon icon-filter-o me-2"></i>查询</d-button>
              <d-button bsStyle="common" (btnClick)="reset()"> <i class="icon icon-refresh me-2"></i>重置</d-button>
            </div>
            <div class="btn-group">
              <div class="btn-left">
                <d-button bsStyle="common" (click)="GetLogs()">日志</d-button>
              </div>
            </div>
          </d-col>
        </d-row>
      </div>
      <div class="list-content">
        <d-data-table [dataSource]="tableData" [lazy]="true" [scrollable]="true" [fixHeader]="true"
          [tableWidthConfig]="tableWidthConfig" [tableOverflowType]="'auto'" [scrollable]="true"
          (checkAllChange)="getCheckedRows()" (rowCheckChange)="getCheckedRows()" [resizeable]="true">
          <thead dTableHead [checkable]="true">
            <tr dTableRow>
              <th dHeadCell [fixedLeft]="'80px'">
                <span>操作</span>
              </th>
              <th dHeadCell *ngFor="let colOption of dataTableOptions.columns">{{ colOption.header }}</th>
            </tr>
          </thead>
          <tbody dTableBody>
            <ng-template let-rowItem="rowItem" let-rowIndex="rowIndex" let-nestedIndex="nestedIndex">
              <tr dTableRow>
                <td dTableCell [fixedLeft]="'0px'">
                  <d-checkbox [disabled]="false" [showAnimation]="true" [ngModelOptions]="{ standalone: true }"
                    [ngModel]="rowItem.$checked" dTooltip [halfchecked]="rowItem.$halfChecked" [showGlowStyle]="false"
                    (ngModelChange)="onRowCheckChange($event, rowIndex, nestedIndex, rowItem)"></d-checkbox>
                </td>
                <td dTableCell [rowItem]="rowItem" [fixedLeft]="'80px'">
                  <span><a class="devui-link ms-3" (click)="ruku(rowItem)"
                      [class.disabled]="!rowItem.isAudit || (rowItem.quantity-calculateEntryQuantitySum(rowItem))<=0">入库</a></span>
                  <span><a class="devui-link ms-3" (click)="isAudit(rowItem)"
                      [class.disabled]="rowItem.isAudit">审核</a></span>
                  <span><a class="devui-link ms-3" (click)="UnAuditProductionWarehousing(rowItem)"
                      [class.disabled]="!rowItem.isAudit">反审核</a></span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.productionWarehousingNum">{{
                    rowItem?.productionWarehousingNum}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.productionWarehousingNum">{{
                    rowItem?.orderType}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.jobNum">{{ rowItem?.jobNum}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.sale">{{ rowItem?.sale}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.partNum">{{ rowItem?.partNum}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.partName">{{ rowItem?.partName}}</span>
                </td>
                <td dTableCell>
                  <span>
                    <d-tag [tag]="rowItem?.isInspection | booleanToText: '检验':'不检验'"
                      [labelStyle]="rowItem?.isInspection === true ? '检验' : '不检验'">
                    </d-tag>
                  </span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.partType">{{ rowItem?.partType}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.quantity">{{ rowItem?.quantity}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip
                    [content]="calculateEntryQuantitySum(rowItem)">{{ calculateEntryQuantitySum(rowItem)}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.partUOM">{{ rowItem?.partUOM}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span>
                    <div dImagePreview>
                      <d-badge *ngIf="rowItem.qrCode" [count]="getImagesArray2(rowItem.qrCode).length" status="success">
                        <ng-container *ngFor="let imageUrl of getImagesArray2(rowItem.qrCode); let i = index">
                          <img *ngIf="getImagesArray2(rowItem.qrCode).length > 0" [src]="imageUrl" alt="图片"
                            height="22px" [ngStyle]="{'display': i === 0 ? 'block' : 'none'}" />
                        </ng-container>
                      </d-badge>
                    </div>
                  </span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.createUserName">{{ rowItem?.createUserName}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.dateTime">{{ rowItem?.dateTime}}</span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.isWarehousing | booleanToText:'已入库':'未入库'">
                    <d-tag [tag]=" rowItem?.isWarehousing | booleanToText:'已入库':'未入库'"
                      [labelStyle]="rowItem?.isWarehousing"></d-tag>
                  </span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.isAudit | booleanToText:'已审核':'未审核'">
                    <d-tag [tag]=" rowItem?.isAudit | booleanToText:'已审核':'未审核'" [labelStyle]="rowItem?.isAudit">
                    </d-tag>
                  </span>
                </td>
                <td dTableCell [rowItem]="rowItem" [field]="'showType'">
                  <span dTooltip [content]="rowItem?.note">{{rowItem?.note}}</span>
                </td>
                <td dTableCell>
                  <span class="ellipsis" (click)="GetLogById(rowItem)"> <a class="devui-link">查看</a></span>
                </td>
              </tr>
            </ng-template>
          </tbody>
        </d-data-table>
      </div>
      <div class="page-footer">
        <div>
          <p>已选 <span class="underline">{{checkedIds.length}}</span> 条
            <a (click)="cleared()" class="cleared">清空</a>
          </p>
        </div>
        <d-pagination [size]="'sm'" [canViewTotal]="true" [canChangePageSize]="true" [canJumpPage]="true" [maxItems]="5"
          [total]="this.pager.total" [pageSizeOptions]="this.pageSizeOptions" [(pageSize)]="pager.pageSize"
          [(pageIndex)]="pager.pageIndex" (pageIndexChange)="pageIndexChange($event)"
          (pageSizeChange)="pageSizeChange($event)">
        </d-pagination>
      </div>
    </div>

  </div>
</div>
<d-toast [value]="msgs" [life]="2000" [styleClass]="'custom-class'" [style]="{ left: '50%',top:'10px' }"></d-toast>
